import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
class ResLoader {
  private gltfLoader: GLTFLoader;
  constructor() {
    const dracoLoader = new DRACOLoader();
    dracoLoader.setDecoderPath('js/libs/draco/gltf/');
    this.gltfLoader = new GLTFLoader();
    this.gltfLoader.setDRACOLoader(dracoLoader);
  }

  /**
   * loadGLTF 加载GLTF
   */
  public loadGLTF(
    filePath: string,
    onProgress?: (event: ProgressEvent) => void
  ): Promise<GLTF> {
    return this.gltfLoader.loadAsync(filePath, onProgress);
  }
}

export const _ResLoader = new ResLoader();
